angular.module('mamApp').controller('appPlayManagerController', ['$scope',  '$state','DataManager','paramsManager','api',
    function ($scope, $state,DataManager,paramsManager , api){
    
        $scope.search = {
            clientType:$state.params.clientType,
            pageNo: $state.params.pageNo || 1,
            pageSize: $state.params.pageSize || 10,
            "X-Auth-Token":$scope.userInfo.token
        };

        $scope.paginationConf = {
            currentPage: $state.params.pageNo || 1,
            itemsPerPage: $state.params.pageSize || 10,
            pagesLength: 9,
            search: 0,
            onChange: function () {
                $scope.search.pageNo = this.currentPage;
                $scope.search.pageSize = this.itemsPerPage;
                $state.go($state.current.name, $scope.search)
            }
        }
        $scope.table = JSON.parse(localStorage.getItem("codeTable"));
        $scope.downHref=api+"/admin/stat/play/playChannel/export/"+$scope.search.clientType
            +paramsManager.query($scope.search);
        $scope.noPermission=false;
        DataManager.channelPlayOverviewStat([$scope.search.clientType,$scope.search.pageNo, $scope.search.pageSize]).then(function (result) {
            if(result.data.c=="n"){
                $scope.noPermission=true;
            }else{
                $scope.noPermission=false;
                $scope.list = result.data.pageList;
                $scope.paginationConf.totalItems = result.data.total;
              }
              
            });


    }])